<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="p" uri="/WEB-INF/pages.tld"%>  
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page import="com.taobao.api.domain.Trade" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	String webContext = request.getContextPath();
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>订单详细信息</title>
	<style type="text/css">
		.button {  
		    display: inline-block;  
		    zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */  
		    *display: inline;  
		    vertical-align: baseline;  
		    margin: 0 2px;  
		    outline: none;  
		    cursor: pointer;  
		    text-align: center;  
		    text-decoration: none;  
		    font: 14px/100% Arial, Helvetica, sans-serif;  
		    padding: .5em 2em .55em;  
		    text-shadow: 0 1px 1px rgba(0,0,0,.3);  
		    -webkit-border-radius: .5em;   
		    -moz-border-radius: .5em;  
		    border-radius: .5em;  
		    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);  
		    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);  
		    box-shadow: 0 1px 2px rgba(0,0,0,.2);  
		} 
		.white {  
		    color: #606060;  
		    border: solid 1px #b7b7b7;  
		    background: #fff;  
		    background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));  
		    background: -moz-linear-gradient(top,  #fff,  #ededed);  
		    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');  
		} 
		.white:hover {  
		    background: #ededed;  
		    background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dcdcdc));  
		    background: -moz-linear-gradient(top,  #fff,  #dcdcdc);  
		    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dcdcdc');  
		}  
		.white:active {  
		    color: #999;  
		    background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#fff));  
		    background: -moz-linear-gradient(top,  #ededed,  #fff);  
		    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff');  
		}   
	</style>
	
	<script language="JavaScript"  >  
   		var req;  
   		function createXMLHttpRequest() {   
   			if(window.XMLHttpRequest) {  
   	   		    //IE7, Firefox, Opera支持  
   	   		    req = new XMLHttpRequest();  
   	   		}else if(window.ActiveXObject) {  
   	   		    //IE5,IE6支持  
   	   		    req = new ActiveXObject("Microsoft.XMLHTTP");  
   	   		} 
		}
   		function callBack(){
   		    if(req.readyState == 4){   
   		    	closediv();
   		        if(req.status == 200 || req.status == 0){   
   					var message = req.responseText;
   					if(message == "ok")
   					{
   						alert("同步到U9成功！");
   						reloadOpener();
   	   					closeWin();
   					}else if(message == "synU9Fail"|| message=="false"){
   						alert("同步到U9失败，请联系管理员！");
   					}else if(message == "selectTmallFail"){
   						alert("同步失败，调用天猫接口超时，请稍后重试！");
   					}else if(message == "isDone"){
   						alert("该订单已同步到U9，请勿重复提交！");
   						reloadOpener();
   	   					closeWin();
   	   				}
   					//reloadOpener();
   					//closeWin();
   		        } else {   
   		            alert("xmlHttp 请求失败，错误码 " + req.status);   
   		        }   
   		    }   
   		}
   		function synToU9(src){ 
   			var time =new Date();
   			var retVal = showModalDialog (src+"?time="+time,"","location:No;status:No;help:No;dialogWidth:600px;dialogHeight:400px;resizable:NO;scroll:NO;");
   			if(retVal!=null){
   				//for(i=0;i<retVal.length;i++)   
   	   	   			//alert(retVal[i]); 
   	   	   		showdiv("同步订单中，请耐心等待....");
   				createXMLHttpRequest();
   	   			var url="<s:url action='synOrder2U9'/>?uid=<s:property value="order.id" />&invoice="+retVal[1]+"&express="+retVal[2]+"&gifts="+retVal[3];
   	   			req.open("POST", encodeURI(url), true);
   	   			req.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded" ) ; 
   	   			req.onreadystatechange=callBack;   
   	   			req.send(null);
   	   		} 
   			
   		} 

   		function closeWin(){  
   		   window.open("","_self");  
   		   top.opener=null;  
   		   top.close();  
   		}  

   		function reloadOpener()
   		{
   			try
   			{
   				window.opener.location.reload();
   			}
   			catch(e)
   			{
   			}
   		}

	   	//关闭等待窗口
	   	function closediv() {
	   	    //Close Div 
	   	    document.body.removeChild(document.getElementById("bgDiv"));
	   	    document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
	   	    document.body.removeChild(document.getElementById("msgDiv"));
	   	}
	   	//显示等待窗口
	   	function showdiv(str) {
	   	    var msgw, msgh, bordercolor;
	   	    msgw = 400; //提示窗口的宽度 
	   	    msgh = 100; //提示窗口的高度 
	   	    bordercolor = "#336699"; //提示窗口的边框颜色 
	   	    titlecolor = "#99CCFF"; //提示窗口的标题颜色 
	   	 
	   	    var sWidth, sHeight;
	   	    sWidth = window.screen.availWidth;
	   	    sHeight = window.screen.availHeight;
	   	 
	   	    var bgObj = document.createElement("div");
	   	    bgObj.setAttribute('id', 'bgDiv');
	   	    bgObj.style.position = "absolute";
	   	    bgObj.style.top = "0";
	   	    bgObj.style.background = "#777";
	   	    bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	   	    bgObj.style.opacity = "0.6";
	   	    bgObj.style.left = "0";
	   	    bgObj.style.width = sWidth + "px";
	   	    bgObj.style.height = sHeight + "px";
	   	    document.body.appendChild(bgObj);
	   	    var msgObj = document.createElement("div");
	   	    msgObj.setAttribute("id", "msgDiv");
	   	    msgObj.setAttribute("align", "center");
	   	    msgObj.style.position = "absolute";
	   	    msgObj.style.background = "white";
	   	    msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
	   	    msgObj.style.border = "1px solid " + bordercolor;
	   	    msgObj.style.width = msgw + "px";
	   	    msgObj.style.height = msgh + "px";
	   	    msgObj.style.top = (document.documentElement.scrollTop + (sHeight - msgh) / 2) + "px";
	   	    msgObj.style.left = (sWidth - msgw) / 2 + "px";
	   	    var title = document.createElement("h4");
	   	    title.setAttribute("id", "msgTitle");
	   	    title.setAttribute("align", "right");
	   	    title.style.margin = "0";
	   	    title.style.padding = "3px";
	   	    title.style.background = bordercolor;
	   	    title.style.filter = "progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
	   	    title.style.opacity = "0.75";
	   	    title.style.border = "1px solid " + bordercolor;
	   	    title.style.height = "18px";
	   	    title.style.font = "12px Verdana, Geneva, Arial, Helvetica, sans-serif";
	   	    title.style.color = "white";
	   	    //title.style.cursor = "pointer";
	   	    //title.innerHTML = "关闭";
	   	    //title.onclick = closediv;
	   	    document.body.appendChild(msgObj);
	   	    document.getElementById("msgDiv").appendChild(title);
	   	    var txt = document.createElement("p");
	   	    txt.style.margin = "1em 0";
	   	    txt.setAttribute("id", "msgTxt");
	   	    txt.innerHTML = str;
	   	    document.getElementById("msgDiv").appendChild(txt);
	   	 	//alert("1");
	   	}
	   	//屏蔽F5
	   	document.onkeydown = mykeydown;
	   	function mykeydown() {
	   	    if (event.keyCode == 116) //屏蔽F5刷新键   
	   	    {
	   	        window.event.keyCode = 0;
	   	        return false;
	   	    }
	   	}  
	</script>  
</head>
<body>
	<H2 align="center">订单详细信息</H2>
	<table align="center" width="90%">
		<tr>
			<td align="right">
				<s:if test="order.synStatus==0">
					<a href="javascript:synToU9('synOrder2U9Detail')" class="button white">同步到U9</a>					
				</s:if>
				<a href="javascript:closeWin()" class="button white">关闭</a>
			</td>
		</tr>
	</table>
	
	<s:form  method="post" theme="simple">
	<table border="1" align="center" width="90%">
		<tr>
			<td colspan="6" style="font-weight:bolder;background: lightgray;">同步信息</td>
		</tr>
		<tr>
			<td align="right" style="font-weight:bolder;width: 16%;">同步状态：</td>
			<td><s:select name="order.synStatus" list="#{1:'已同步',0:'未同步',2:'手工同步'}" disabled="true"/></td>
			<td align="right" style="font-weight:bolder;width: 16%;">天猫单号：</td>
			<td><s:property value="order.tmallID" /></td>
			<!--td><s:textfield name="#request.ord.tmallID" disabled="true"/></td-->
			<td align="right" style="font-weight:bolder;width: 16%;">天猫订单创建时间：</td>
			<td><s:date name="order.createDate" format="yyyy-MM-dd HH:mm"/></td>
		</tr>
		<tr>
			<td align="right" style="font-weight:bolder">U9单号ID：</td>
			<td><s:property value="order.u9ID" />&nbsp;</td>
			<td align="right" style="font-weight:bolder">同步人：</td>
			<td><s:property value="order.synUserName"/>&nbsp;</td>
			<td align="right" style="font-weight:bolder">同步到U9时间：</td>
			<td><s:date name="order.synDate" format="yyyy-MM-dd HH:mm"/>&nbsp;</td>
		</tr>
		<tr>
			<td align="right" style="font-weight:bolder">快递公司：</td>
			<td><s:property value="order.express"/>&nbsp;</td>
			<td align="right" style="font-weight:bolder">发票抬头：</td>
			<td><s:property value="order.invoice"/>&nbsp;</td>
			<td align="right" style="font-weight:bolder">&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<s:iterator value="order.orderDetail" id="synord" status="synindex" >
			<s:if test="#synindex.first" >
				<tr>
					<td colspan="6" style="font-weight:bolder;background: lightgray;">赠品信息：</td>
				</tr>
				<tr>
					<td colspan="2" align="center" style="font-weight:bolder;">赠品名称</td>
					<td colspan="2" align="center" style="font-weight:bolder;">U9料号</td>
					<td colspan="2" align="center" style="font-weight:bolder;">数量</td>
				</tr>
				
			</s:if>
			<tr>
				<td colspan="2" align="center"><s:property value="gift.name" />&nbsp;</td>
				<td colspan="2" align="center"><s:property value="gift.itemCodeU9" />&nbsp;</td>
				<td colspan="2" align="center"><s:property value="giftNum" />&nbsp;</td>
			</tr>
		</s:iterator>
		<tr>
			<td colspan="6" style="font-weight:bolder;background: lightgray;">订单信息</td>
		</tr>
		<tr height="60px">
			<td  align="right" style="font-weight:bolder">收货地址：</td>
			<td style="word-break:break-all" colspan="5"><s:property value="t.receiverName" />,<s:property value="t.receiverMobile" />,
			<s:property value="t.receiverState" /> <s:property value="t.receiverCity" /> <s:property value="t.receiverDistrict" /> <s:property value="t.receiverAddress" />,<s:property value="t.receiverZip" /></td>
		</tr>
		<tr height="60px">
			<td  align="right" style="font-weight:bolder">买家留言：</td>
			<td style="word-break:break-all" colspan="5"><s:property value="t.buyerMessage"/>&nbsp;</td>
		</tr>	
		<tr height="60px">
			<td  align="right" style="font-weight:bolder">备忘：</td>
			<td style="word-break:break-all" colspan="5"><s:property value="t.sellerMemo"/>&nbsp;</td>
		</tr>	
	</table>
	<br></br>
	<table border="1" align="center" width="90%">
		<tr style="background: lightgray;">
			<th>商品</th>
			<th>单价（元）</th>
			<th>数量</th>
			<th>优惠（元）</th>
			<th>运费</th>
		</tr>
		<s:iterator value="t.orders" id="ord" status="index" >
			<tr height="50px">
				<td width="50%">
					<table>
						<tr>
							<td rowspan="2">&nbsp;<img src="<s:property value="picPath"/>" height="50px"/>&nbsp;</td>
							<td>
								<s:if test="title.length()>45">    
									<li><s:property value="title.substring(0,45)+'...'" />    
								</s:if>    
								<s:else>    
									<li><s:property value="title" />    
								</s:else>   	
							</td>
						</tr>
						<tr>
							<td><li><s:property value ="skuPropertiesName"/></td>
						</tr>
					</table>
				</td>
				<td align="center"><s:property value ="price"/></td>
				<td align="center"><s:property value ="num"/></td>
				<td align="center"><s:property value ="discountFee"/></td>
				<s:if test="#index.first" >
					<td  rowspan="<s:property value="t.orders.size()"/>" align="center" width="80px"><s:property value ="t.postFee"/></td>
				</s:if>
			</tr>
		</s:iterator>
		<tr style="background: lightgray;">
			<td colspan="5" align="right"><strong>应收款：¥<s:property value="t.payment"/></strong>&nbsp;</td>
		</tr>
	</table>
	</s:form>
</body>
</html>